import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:znmm/UI/A_Common/custom_behavior.dart';
import 'package:znmm/config/app_asset.dart';
import 'package:znmm/config/app_color.dart';
import 'login_page.dart';
import 'pwd_login_view.dart';

class LoginView extends StatefulWidget {
  const LoginView({super.key});

  @override
  State<LoginView> createState() => _LoginViewState();
}

class _LoginViewState extends State<LoginView> {
  LoginType _loginType = LoginType.pwdLogin;

  @override
  void initState() {
    super.initState();

    // 使用Get.arguments获取传递的参数
    _loginType = Get.arguments ?? LoginType.pwdLogin;
    print("loginType:$_loginType");
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColor.white,
      appBar: AppBar(
        backgroundColor: Colors.white,
        iconTheme: IconThemeData(color: AppColor.greyA7A9B7),
      ),
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: 20.w),
        child: CustomBehavior(
          child: SingleChildScrollView(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Image.asset(
                  AppAsset.imageLogo,
                  width: 0.5 * Get.width,
                  fit: BoxFit.contain,
                ),

                Visibility(
                  visible: _loginType == LoginType.pwdLogin,
                  child: const PwdLoginView(),
                ),
                // Visibility(
                //   visible: _loginType == LoginType.phoneLogin,
                //   child: const PhoneLoginView(),
                // ),
                // Visibility(
                //   visible: _loginType == LoginType.emailLogin,
                //   child: const EmailLoginView(),
                // ),
                // Visibility(
                //   visible: _loginType == LoginType.subLogin,
                //   child: const SubAccountLoginView(),
                // ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
